Repository navigation
fix(gateway): send a streamed start failure's error and DONE as two events - #348
Merged
Merged
Conversation
…vents
sseFailure wrote "data: {error}\ndata: [DONE]\n\n", one SSE event with two
data lines. A client joins those lines with a newline, so it read the
error object followed by "[DONE]", failed to parse it and reported
"malformed server-sent event JSON" with no reason. A blank line now ends
the error event before DONE.
TestKeepAliveFailureEmitsErrorEvent reads the stream the way an SSE
client does and requires each event's data to be JSON or [DONE].
Closes #346
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #346.
What changes
When a streamed request's engine never came up,
sseFailurewrotedata: {error}\ndata: [DONE]\n\n. That is one server-sent event with two data lines. An SSE client joins the data lines of an event with a newline, so it got the error object followed by[DONE], could not parse it, and reported "malformed server-sent event JSON" with no reason.A blank line now ends the error event before
[DONE], so the client gets two events. The first is the OpenAI-shaped error object, which already names the reason, for examplestrata got no berth: ... held by strata-sc117 [foreground, active].Proof
TestKeepAliveFailureEmitsErrorEventnow parses the stream the way an SSE client does and requires each event's data to be JSON or[DONE]. Without the fix it fails with the joined{...}\n[DONE]data.go test ./..., the Windows build and vet, golangci-lint 2.14.0.